{% extends 'Base/main.0.html.twig' %}

{% block myJs %}
    <script>

        $(function () {
            $("#txtKeywords").on("keypress", function (event) {
                if (event.keyCode == 13) {
                    __doPostBack('lbtnSearch', '')
                    return false;
                }
            });
            $(".edit_val").on("keypress", function (event) {
                if (event.keyCode == 13) {
                    var id = $(this).data("id")
                    var name = $(this).data("name")
                    var selector = $(this).data("selector")
                    __doPostBack('setAttr','id='+id+'&'+name+'='+ $(selector).val())
                    return false;
                }
            });
        })
    </script>
{% endblock %}
{% block content %}
    <div id="page" class="pad10">
        {% block statistic %}
            {#这里可以放一下统计数据类的东西#}
        {% endblock %}
        <form lay-filter="mainform" class="layui-form" method="get"
              action="{{ urls.toolUrl is defined ? urls.toolUrl : '' }}" id="form1">
            {% block actionScript %}
                <div class="aspNetHidden">
                    <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value=""/>
                    <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value=""/>
                </div>
                <script type="text/javascript">
                    var theForm = document.forms['form1'];
                    if (!theForm) {
                        theForm = document.form1;
                    }

                    function __doPostBack(eventTarget, eventArgument) {
                        if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
                            theForm.__EVENTTARGET.value = eventTarget;
                            theForm.__EVENTARGUMENT.value = eventArgument;
                            theForm.submit();
                        }
                    }

                </script>
            {% endblock %}
            {% block toolbar -%}
                <!--工具栏-->
                <div class="flex-r">
                    <div>
                        <div class="layui-btn-group">
                            {% block addBtn %}
                                <a href="{{ urls.addUrl is defined ? urls.addUrl : '' }}">
                                    <div class="layui-btn layui-btn-normal"><span class="fa fa-plus"></span> 新增</div>
                                </a>
                            {% endblock %}

                            {% block delBtn %}
                                <div class="layui-btn layui-btn-normal" id="ComListCheckAll">
                                    <span class="fa fa-check-square-o"></span>
                                    <span class="text">全选</span>
                                </div>
                                <div class="layui-btn layui-btn-normal" id="ComListDelete">
                                    <span class="fa fa-trash-o"></span> 删除
                                </div>
                            {% endblock %}
                        </div>
                    </div>
                    <div class="flex1">
                        {% block options %}
                            <div class="menu-list">
                                {#{{ dump(tools) }}#}
                                {% if tools is not defined %}
                                    {% set tools = [] %}
                                {% endif %}
                                {% for key , classes in tools %}
                                    {% set default = "请选择分类" %}
                                    {% set classes = classes %}
                                    <div class="rule-single-select layui-inline">
                                        <select name="cond[{{ key }}]" onchange="javascript:__doPostBack('searchCond','')" >
                                            <option value="" {{app.request.get("cond")[key] is defined and app.request.get("cond")[key] == "" ? ' selected="selected"' : "" }} >{{ default }}</option>
                                            {% for class in classes %}
                                                <option value="{{ class.id }}"
                                                        {{app.request.get("cond")[key] is defined and  app.request.get("cond")[key] == class.id ? ' selected="selected"' : "" }}
                                                >{{ class.name }}</option>
                                            {% endfor %}
                                        </select>
                                    </div>
                                {% endfor %}
                            </div>
                        {% endblock %}
                    </div>
                    <div class="flex-r">
                        {% block searchBox %}
                            <input id="txtKeywords"
                                   type="text" name="txtKeywords"
                                   value="{{ app.request.get("txtKeywords") }}" required
                                   lay-verify="required" placeholder="请输入标题" autocomplete="off"
                                   class="layui-input">

                            <a class="layui-btn layui-btn-normal cf"
                               href="javascript:__doPostBack('lbtnSearch','')">
                                <span class="fa fa-search cf"></span>
                            </a>
                        {% endblock %}
                    </div>
                </div>
                <!--/工具栏-->
            {% endblock %}
            {% block main %}
                <!--列表-->
                <table class="layui-table" lay-skin="line">
                    <thead>
                    {% block tableHead %}
                    {% endblock %}
                    </thead>
                    <tbody>
                    {% block tableList %}
                    {% endblock %}
                    </tbody>
                </table>
                <!--/列表-->
            {% endblock %}
            {% block page %}
                <!--内容底部-->
                <div class="line20"></div>
                {% if page is defined %}
                    <div class="pagelist ">
                        <div class="l-btns layui-inline">
                            <span>显示</span>
                            {{ page.perPage }}
                            <span>条/页</span>

                            <span>共 {{ page.total }} 条记录</span>
                        </div>
                        <div id="PageContent" class="default flex-r flex-center">
                            <div class="flex1">{{ page.page  | raw }}</div>
                        </div>
                    </div>
                {% endif %}
                <!--/内容底部-->
            {% endblock %}
        </form>
    </div>

{% endblock %}